<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button class="ajax-btn">发送ajax请求</button>
  <button class="img">发送显示图片请求</button>
  <div></div>
</body>

</html>
<script src="./lib/jquery-3.2.1.min.js"></script>
<script>
  //ajax请求
  $('.ajax-btn').click(() => {
    $.ajax({
      type: 'get',
      url: 'http://localhost:3000/index',
      data: {}
    }).then(res => {
      $('div').append(res)
    })
  })
  //图片请求
  $('.img').click(() => {
    $.ajax({
      type: 'post',
      url: 'http://localhost:3000/img',
      data: {
        code: 1
      }
    })
  })
</script>